// DiplomaticMessageBase.cs
//
// Copyright (c) 2007 Mike Strobel
//
// This source code is subject to the terms of the Microsoft Reciprocal License (Ms-RL).
// For details, see <http://www.opensource.org/licenses/ms-rl.html>.
//
// All other rights reserved.

using System;
using System.Linq;
using Supremacy.Entities;
using Supremacy.Game;

namespace Supremacy.Diplomacy
{
    public abstract class DiplomaticMessageBase
    {
        public GameObjectID SenderID { get; private set; }
        public GameObjectID RecipentID { get; private set; }

        public Civilization Sender
        {
            get { return GameContext.Current.Civilizations[SenderID]; }
        }

        public Civilization Recipient
        {
            get { return GameContext.Current.Civilizations[RecipentID]; }
        }

        public DiplomaticMessageBase(Civilization sender, Civilization recipient)
        {
            if (sender == null)
                throw new ArgumentNullException("sender");
            if (recipient == null)
                throw new ArgumentNullException("recipient");
            this.SenderID = sender.CivID;
            this.RecipentID = recipient.CivID;
        }

        public DiplomaticMessageBase(GameObjectID senderId, GameObjectID recipientId)
        {
            if (!senderId.IsValid)
                throw new ArgumentException("invalid object id", "senderId");
            if (!recipientId.IsValid)
                throw new ArgumentException("invalid object id", "recipientId");
            this.SenderID = senderId;
            this.RecipentID = recipientId;
        }
    }
}